﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI;

namespace Adartse.Sharepoint.WebPartCode
{
    public class AWPBase : WebPart
    {
        protected bool _error = false;
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            //Only if we need Ajaxifyed webparts
            //ScriptManager sm = ScriptManager.GetCurrent(this.Page);
            //if (sm == null)
            //{
            //    sm = new ScriptManager();
            //    this.Controls.AddAt(0, sm);
            //}
        }

        /// <summary>
        /// Clear all child controls and add an error message for display.
        /// </summary>
        /// <param name="ex"></param>
        protected void HandleException(Exception ex)
        {
            this._error = true;
            this.Controls.Clear();
            this.Controls.Add(new LiteralControl(ex.ToString()));
        }
    }
}

